<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <body>

        <ui:composition template="./../layout/page.xhtml">

            <ui:define name="top">
            </ui:define>

            <ui:define name="content">
                <h2>Список договоров</h2>
                <hr />
                <h:form id="frmListContracts">
                    
                    <p:dataTable id="tabListContracts" var="item" value="#{mbVContract.allMy}" paginator="true" rows="50" selection="#{mbVContract.contract}" selectionMode="single" rowKey="#{item.id}" filteredValue="#{mbVContract.listContractFilter}">
                        
                        <p:ajax event="rowSelect" update=":frmListContracts:panelDetaleContract" oncomplete="dialogDetaleContract.show()"/>
                        
                        <f:facet name="header">
                            Список договоров
                        </f:facet>
                        <p:column headerText="Дата" filterBy="Data_reg">
                            <h:outputText value="#{item.regDate}"/>
                        </p:column>
                        <p:column headerText="Номер" filterBy="Number">
                            <h:outputText value="#{item.id}"/>
                        </p:column>
                        <p:column headerText="Заказчик" filterBy="Client">
                            <h:outputText value="#{item.clientFlId==null ? item.clientUlId : item.clientFlId}"/>
                        </p:column>
                        <p:column headerText="Транспорт" filterBy="Transport">
                            <h:outputText value="#{item.transport}"/>
                        </p:column>
                        <p:column headerText="Дата выезда" filterBy="WorkDate">
                            <h:outputText value="#{item.workDate}"/>
                        </p:column>
                        <p:column headerText="Адрес объекта" filterBy="Address">
                            <h:outputText value="#{item.address}"/>
                        </p:column>
                        <p:column>
                            <p:commandButton value="Редактировать" actionListener="#{mbVContract.editorContract(item.id)}"/>
                        </p:column>
                    </p:dataTable>
                    <p:button value="Новый договор" outcome="/contract/contract" />                    
                    
                    <p:dialog header="Информация о договоре" widgetVar="dialogDetaleContract" resizable="false">
                        <h:panelGrid id="panelDetaleContract" columns="2">
                            <p:outputLabel value="Дата"/>
                            <h:outputText value="#{mbVContract.contract.regDate}"/>
                            <p:outputLabel value="Номер"/>
                            <h:outputText value="#{mbVContract.contract.id}"/>
                            <p:outputLabel value="Заказчик"/>
                            <h:outputText value="#{mbVContract.contract.clientFlId==null ? mbVContract.contract.clientUlId : mbVContract.contract.clientFlId}"/>
                            <p:outputLabel value="Транспорт"/>
                            <h:outputText value="#{mbVContract.contract.transport}"/>
                            <p:outputLabel value="Дата выезда"/>
                            <h:outputText value="#{mbVContract.contract.workDate}"/>
                            <p:outputLabel value="Адрес объекта"/>
                            <h:outputText value="#{mbVContract.contract.address}"/>
                        </h:panelGrid>
                    </p:dialog>
                                    
                </h:form>
                
            </ui:define>

            <ui:define name="bottom">
            </ui:define>

        </ui:composition>

    </body>
</html>

